{template 'common/header'}
{template 'common'}
<div class="main">
<ul class="nav nav-tabs">
	<li><a href="{php echo $this->createWebUrl('order',array('op'=>'list','hotelid'=>$hotelid,'roomidid'=>$roomidid));}">订单管理</a></li>
	<li class="active"><a href="{php echo $this->createWebUrl('order',array('op'=>'edit','id'=>$id));}">订单处理</a></li>
</ul>
<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data" onsubmit="return formcheck();">
	<input type="hidden" name="id" value="{$item['id']}">
	<input type="hidden" name="oldstatus" id="oldstatus" value="{$item['status']}">
	<div class="panel panel-default">
		<div class="panel-heading">
			订单处理
		</div>
		<div class="panel-body">
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">酒店名称</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$hotel['title']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">房间名称</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$room['title']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">房间名称</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					 {$room['title']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">房量/房态</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					<select multiple="true" name="room_list" id="room_list" style="height:200px" class='form-control'>
						{loop $date_array $row}
						<option value="{$row['month']}-{$row['day']}|{$list[$row['time']]['status']}|{$list[$row['time']]['num']}">
							{$row['month']}-{$row['day']} --
							{if $list[$row['time']]['status'] == 1 && ($list[$row['time']]['num'] > 0 || $list[$row['time']]['num'] == '不限')}
							有房
							--
							{$list[$row['time']]['num']}
							{else}
							无房
							{/if}
						</option>
						{/loop}
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">用户类型</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
                {if $member_info['isauto'] == 1}
                微信用户
                {else}
                会员用户
                {/if}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">预定人</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$item['name']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">联系人</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$item['contact_name']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$item['mobile']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">到店时间</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{php echo date("Y-m-d",$item['btime']); }
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">离店时间</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{php echo date("Y-m-d",$item['etime']); }
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">住几晚</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$item['day']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">预定数量</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{$item['nums']}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">单价</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
                {if $member_info['isauto'] == 1}
                {$item['cprice']}(优惠价)
                {else}
                {$item['mprice']}(会员价)
                {/if}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付方式</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
                {if $item['paytype']==1}
                余额支付
                {else if $item['paytype']==21}
                微支付
                {else if $item['paytype']==22}
                支付宝
                {else}
                到店付款
                {/if}
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单时间</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					{php echo date("Y-m-d H:i:s",$item['time']); }
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">客户留言</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					<textarea readonly style="height:100px;" class="form-control richtext-clone" name="remark" cols="70" id="">{$item['remark']}</textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">操作</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					<!--<select name="status" class="form-control" id="status">-->
						<!--<option value="-1" {if $item['status'] == -1 } selected="selected"{/if}>订单取消</option>-->
						<!--<option value="1" {if $item['status'] == 1 } selected="selected"{/if}>订单确认</option>-->
						<!--<option value="2" {if $item['status'] == 2 } selected="selected"{/if}>-->
						<!--{if $item['paytype']==0}订单拒绝{else}订单退款{/if}</option>-->
						<!--<option value="3" {if $item['status'] == 3 } selected="selected"{/if}>订单完成</option>-->
					<!--</select>-->
					<button type="button" class="btn but{if $item['status'] == -1} btn-primary{/if} btn-default"  value="-1">订单取消</button>
					<button type="button" class="btn but{if $item['status'] == 1} btn-primary{/if} btn-default"  value="1">订单确认</button>
					<button type="button" class="btn but{if $item['status'] == 2} btn-primary{/if} btn-default"  value="2">{if $item['paytype']==0}订单拒绝{else}订单退款{/if}</button>
					<button type="button" class="btn but{if $item['status'] == 3} btn-primary{/if} btn-default"  value="3">订单完成</button>
					<input type="hidden" id="status" name="status" value="{$item['status']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">备注</label>
				<div class="col-sm-9 col-xs-12 form-control-static">
					<textarea style="height:100px;" class="form-control richtext-clone" name="msg" cols="70" id="reply-add-text">{$item['msg']}</textarea>
				</div>
			</div>
		</div>
	</div>
	<div class="form-group col-sm-12">
		<input type="hidden" name="old_status" value="{$item['status']}" />
		<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
		<input type="hidden" name="token" value="{$_W['token']}" />
	</div>
</form>

<script language="JavaScript">
	function formcheck(){
		var ok = true;
		if($("#status").val()==1 && $("#oldstatus").val()!=1){
			$("#room_list option").each(function(){
				var val = $(this).val().split("|");
				if(val[1] == 0){
					alert(val[0] + "无房");
					ok =false;
					return false;
				} else {
					if (val[2] != '不限') {
						if(parseInt(val[2]) == 0) {
							alert(val[0] + "没有空房间");
							ok =false;
							return false;
						}
						if(parseInt(val[2]) > 0 && parseInt(val[2]) < {$item['nums']}) {
							alert(val[0] + "房间数量不够");
							ok =false;
							return false;
						}
					}
				}
			});
		}
		return ok;
	}
</script>
	<script>
		require(['bootstrap'],function($){
			$('.but').click(function(){
				$('.but').removeClass('btn-primary');
				$(this).addClass('btn-primary');
				$('#status').val($(this).val()) ;
			});
		});
	</script>
{template 'common/footer'}
